package com.rpframework.module.common.bottom.weixin.util;

import java.util.Set;
import java.util.TreeMap;
import java.util.Map.Entry;

public class WeiXinSignAndPackage {
	
	/**
	 * wxpackage组装原始串
	 * @param treeMap
	 * @return
	 */
	public static String originalString(TreeMap<String,String> treeMap){
		Set<Entry<String, String>> entry = treeMap.entrySet();
		StringBuffer sb = new StringBuffer();
		for(Entry<String,String> obj : entry){
			String k = obj.getKey();
			String v = obj.getValue();
			if(v == null && v.equals(""))
				continue;
			sb.append(k+"="+v+"&");
		}
		String signature=sb.toString();
		//截取最后一位去掉
		signature=signature.substring(0, signature.length()-1);
		return Sha1Util.getSha1(signature);
	}
}
